package com.ibeetl.admin.core.service;


import com.ibeetl.admin.core.dao.CoreAreaDao;
import com.ibeetl.admin.core.entity.CoreArea;



import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;






/**
 * 地区 Service
 */

@Service
@Transactional
public class CoreAreaService extends CoreBaseService<CoreArea>{

    @Autowired private CoreAreaDao coreAreaDao;

    public PageQuery<CoreArea>queryByCondition(PageQuery query){
        PageQuery ret =  coreAreaDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelCoreArea(List<Long> ids){
        try {
            coreAreaDao.batchDelCoreAreaByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除地区失败", e);
        }
    }
    
    public CoreArea getAreaByAreaCode(Long areaCode) {
    	CoreArea template = new CoreArea();
        template.setAreaCode(areaCode);
        CoreArea area = coreAreaDao.templateOne(template);
        
        return area;
    }
}